# $Id: PKGBUILD 173243 2012-12-15 23:55:14Z stephane $
# Maintainer: Stéphane Gaudreault <stephane@archlinux.org>
# Contributor: Alexander Fehr <pizzapunk gmail com>

pkgbase=python-logilab-common
pkgname=('python2-logilab-common' 'python-logilab-common')
pkgver=0.58.3
pkgrel=3
pkgdesc="Useful miscellaneous modules used by Logilab projects"
arch=('any')
url="http://www.logilab.org/project/logilab-common"
license=('LGPL')
makedepends=('python2' 'python')
source=(http://download.logilab.org/pub/common/logilab-common-${pkgver}.tar.gz)
sha1sums=('da1c1b0ff9fd9f76166ef965209b29fa518b4503')

build() {
  cd "${srcdir}"

  cp -a logilab-common-${pkgver}{,-py3}

  cd logilab-common-${pkgver}
  python2 setup.py build

  cd ../logilab-common-${pkgver}-py3

  find test/data -name \*.py -exec 2to3 -nw {} \;

  python3 setup.py build
}

package_python2-logilab-common() {
  depends=('python2')
  cd "${srcdir}"/logilab-common-${pkgver}

  python2 setup.py install --optimize=1 --skip-build --prefix=/usr --root="${pkgdir}"

  mv "${pkgdir}"/usr/bin/pytest{,2}

  # fix permissions ...
  find "${pkgdir}" -type f -exec chmod +r {} \;
}

package_python-logilab-common() {
  depends=('python')
  cd "${srcdir}"/logilab-common-${pkgver}-py3

  python3 setup.py install --optimize=1 --skip-build --prefix=/usr --root="${pkgdir}"

  # fix permissions ...
  find "${pkgdir}" -type f -exec chmod +r {} \;
}
